<?php

/**
 * This is the model class for table "tvisitas_medicas".
 *
 * The followings are the available columns in table 'tvisitas_medicas':
 * @property integer $cod_paciente
 * @property string $fecha_visita
 * @property integer $cod_medico
 * @property string $diagnostico
 * @property string $observaciones
 * @property double $peso
 * @property double $estatura
 * @property string $pulso
 * @property string $sistolica
 * @property string $diastolica
 * @property double $temperatura
 * @property integer $PK_Tvisitas_medicas
 */
class VisitasMedicas extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return VisitasMedicas the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tvisitas_medicas';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('cod_paciente, cod_medico, PK_Tvisitas_medicas', 'numerical', 'integerOnly'=>true),
			array('peso, estatura, temperatura', 'numerical'),
			array('pulso', 'length', 'max'=>30),
			array('sistolica, diastolica', 'length', 'max'=>25),
			array('fecha_visita, diagnostico, observaciones', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('cod_paciente, fecha_visita, cod_medico, diagnostico, observaciones, peso, estatura, pulso, sistolica, diastolica, temperatura, PK_Tvisitas_medicas', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'cod_paciente' => 'Paciente',
			'fecha_visita' => 'Fecha de visita',
			'cod_medico' => 'M&eacute;dico',
			'diagnostico' => 'Diagn&oacute;stico',
			'observaciones' => 'Observaciones',
			'peso' => 'Peso',
			'estatura' => 'Estatura',
			'pulso' => 'Pulso',
			'sistolica' => 'Sist&oacute;lica',
			'diastolica' => 'Diast&oacute;lica',
			'temperatura' => 'Temperatura',
			'PK_Tvisitas_medicas' => 'ID',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('cod_paciente',$this->cod_paciente);
		$criteria->compare('fecha_visita',$this->fecha_visita,true);
		$criteria->compare('cod_medico',$this->cod_medico);
		$criteria->compare('diagnostico',$this->diagnostico,true);
		$criteria->compare('observaciones',$this->observaciones,true);
		$criteria->compare('peso',$this->peso);
		$criteria->compare('estatura',$this->estatura);
		$criteria->compare('pulso',$this->pulso,true);
		$criteria->compare('sistolica',$this->sistolica,true);
		$criteria->compare('diastolica',$this->diastolica,true);
		$criteria->compare('temperatura',$this->temperatura);
		$criteria->compare('PK_Tvisitas_medicas',$this->PK_Tvisitas_medicas);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}